IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Content_SaveContentItem')
	BEGIN
		DROP  Procedure  Content_SaveContentItem
	END

GO

CREATE Procedure Content_SaveContentItem
	(
		@ContentItemID int = NULL OUTPUT,
		@ContentText ntext,
		@Region varchar(50),
		@Revision int,
		@PublishDate datetime = NULL
	)
AS

	IF @ContentItemID IS NULL
	BEGIN
		INSERT INTO Content_ContentItem (ContentText, Region, Revision, PublishDate)
		VALUES (@ContentText, @Region, @Revision, @PublishDate)
		
		SET @ContentItemID = SCOPE_IDENTITY()
	END
	ELSE
	BEGIN
		UPDATE Content_ContentItem
		SET
			ContentText = @ContentText,
			Region = @Region,
			Revision = @Revision,
			PublishDate = @PublishDate
		WHERE ContentItemID = @ContentItemID
	END

GO
